/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metier;

import modele.Claim;
import modele.Company;
import modele.Employee;

/**
 *
 * @author kluck
 */
public class ResponseLetter {
    protected static String templateLetterAccepted = "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ has been "+
            "accepted by our insurance company, and will be fully taken in "+
            "charge.\nYours sincerely,\n\n___EmployeeFirstName___ "+
            "___EmployeeLastName___ from ___CompanyName___";
    protected static String templateLetterRejected = "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ has been "+
            "rejected by our insurance company.\nReason : You either had more "+
            "than 3 responsible accidents in the last year, or we already "+
            "paid more than 3000$ for your insurance in the last year.\nYours "+
            "sincerely,\n\n___EmployeeFirstName___ ___EmployeeLastName___ from " +
            "___CompanyName___";
    protected static String templateSMSAccepted = "SMS from ___CompanyName___.\n" +
            "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ will be taken "+
            "in charge by our insurance company.\n___EmployeeFirstName___ "+
            "___EmployeeLastName___";
    protected static String templateSMSRejected = "SMS from ___CompanyName___.\n" +
            "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ will not be taken "+
            "in charge by our insurance company.\n___EmployeeFirstName___ "+
            "___EmployeeLastName___";
    protected static String templateEmailAccepted = "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ has been "+
            "accepted by our insurance company, and will be fully taken in "+
            "charge.\nYours sincerely,\n\n___EmployeeFirstName___ "+
            "___EmployeeLastName___ (___EmployeeFirstName___.___EmployeeLastName___" +
            "@___CompanyName___.com)";
    protected static String templateEmailRejected = "Dear ___CustomerFirstName___ "+
            "___CustomerLastName___,\nYour claim ___ClaimId___ has been "+
            "rejected by our insurance company.\nReason : You either had more "+
            "than 3 responsible accidents in the last year, or we already "+
            "paid more than 3000$ for your insurance in the last year.\nYours "+
            "sincerely,\n\n___EmployeeFirstName___ ___EmployeeLastName___ " +
            "(___EmployeeFirstName___.___EmployeeLastName___" +
            "@___CompanyName___.com)";
    protected String result;
    
    public ResponseLetter() {
        this.result = "";
    }
    
    public ResponseLetter(Company comp, Claim claim, Employee employee, boolean choice, String type) {
        if (choice) {
            if ("sms".equals(type)) {
                this.result = templateSMSAccepted;
            } else if ("email".equals(type)) {
                this.result = templateEmailAccepted;
            } else {
                this.result = templateLetterAccepted;
            }
        } else {
            if ("sms".equals(type)) {
                this.result = templateSMSRejected;
            } else if ("email".equals(type)) {
                this.result = templateEmailRejected;
            } else {
                this.result = templateLetterRejected;
            }
        }
        this.result = this.result.replaceAll("___CustomerFirstName___",
                claim.getCustomer().getFirstName());
        this.result = this.result.replaceAll("___CustomerLastName___",
                claim.getCustomer().getLastName());
        this.result = this.result.replaceAll("___EmployeeFirstName___",
                employee.getFirstName());
        this.result = this.result.replaceAll("___EmployeeLastName___",
                employee.getLastName());
        this.result = this.result.replaceAll("___ClaimId___",
                claim.getIdClaim().toString());
        this.result = this.result.replaceAll("___CompanyName___",
                comp.getName());
    }
    
    public String getResult() {
        return this.result;
    }

}
